$(document).ready(function() {
    /* 搜索页面 */
    /*$("#text1").on("click",function(){
        alert("hellworl");
    });*/

    //热卖商品
    $.ajax({
        url: "/agriecomIndex/search/hots?page=1&limit=3",
        dataType: "json",
        type: "GET",
        sync:false,
        success: function (data) {          //只取前三个数据
            $.each(data,function(i,ele){
                var num=i+1;
                var div=$(".sb-content>div:nth-child("+num+")");
                $(div.find("a")[0]).attr("href",ele.produceId);                         //图片链接
                $(div.find("a")[0].children[0]).attr("src",ele.produceImg.split(",")[0]);//取第一张放入
                $(div.find("a")[1]).attr("href",ele.produceId);
                $(div.find("a")[1]).html("");
                $(div.find("a")[1]).html(ele.produceName);
                $(div.find("a")[1]).append(`</br></br><div class="rating-star">
														<span class="spr-badge" id="spr_badge_3008529731" data-rating="5.0">
														<span class="spr-starrating spr-badge-starrating">
														
                                                        </span>
														<span class="spr-badge-caption">
														1 review </span>
														</span>
                                                    </div>`);
                $($(div.find("p")[1]).children("span")).html(ele.price+ele.unit);
                starChange('span#spr_badge_3008529731',ele.remarks,i);
            })
        }}
    )
    //广告
    $.ajax({
        url: "/agriecomIndex/search/ad",
        dataType: "json",
        type: "GET",
        success: function (data) {
            $(".slider-banner-wrapper img").attr("src",data[0].pic);

        }}
    )

})
